package org.grow.prac.controller;

import org.grow.prac.domain.Content;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: xwg
 * @CreateDate: 2023/9/20
 */

@RestController
@RequestMapping("/think")
public class ThinkController {

    @GetMapping("/time")
    public String time() {
        return System.currentTimeMillis() + "TIME";
    }

    @GetMapping("/content")
    public Content content() {

        return new Content("Hello, world!", 10);
    }
    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @GetMapping("/redis")
    public String redis(){
        System.out.println(stringRedisTemplate == null);
//        set abcd nice
        ValueOperations<String, String> ops = stringRedisTemplate.opsForValue();
        ops.set("abcd","bad");
        return ops.get("abcd");
    }
}
